<?php
namespace app\index\controller;


use Curl\Curl;
use think\Request;

class Tool
{

    public function index(Request $request)
    {
        $url = '';
        if($request->isPost()){
            $url = $request->param('url','','trim');
            if($url){
                $curl = new Curl();
                $curl -> setUserAgent('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.108 Safari/537.36 2345Explorer/8.7.0.16013');
                $curl -> get($url);
                $response = $curl->response;

                preg_match_all('/"(http[^"]*)"/',$response,$matches);
                if(isset($matches[1])){
                    $matches = $matches[1];
                }else{
                    $matches = [];
                }
                return view('',['url'=>$url,'matches'=>$matches]);
            }

        }
        return view('',['url'=>$url,'matches'=>[]]);
    }

}
